# while循环
print('以下为while循环方式：')
# while循环一
i = 1
while i <= 9:
    a = 1
    while a <= i:
        print('{}*{}={:<4}'.format(a, i, a*i), end='')
        a += 1
    i += 1
    print()
print('-' * 80)

# while循环二
i = 9
while i >= 1:
    a = 1
    while a <= i:
        print('{}*{}={:<4}'.format(a, i, a*i), end='')
        a += 1
    i -= 1
    print()
print('-' * 80)

# while循环三
i = 1
while i <= 9:
    a = 9
    while a > 0:
        if a <= i:
            print('{}*{}={:<4}'.format(a, i, a*i), end='')
        else:
            print(' ' * 8, end='')
        a -= 1
    i += 1
    print()
print('-'*80)

# while循环四
i = 9
while i >= 1:
    a = 9
    while a > 0:
        if a <= i:
            print('{}*{}={:<4}'.format(a, i, a*i), end='')
        else:
            print(' ' * 8, end='')
        a -= 1
    i -= 1
    print()
print('-' * 80)


# for循环
print('以下为for循环方式：')
# for循环一
for i in range(1, 10):
    for a in range(1, i+1):
        print('{}*{}={:<4}'.format(a, i, a*i), end='')
    print()
print('-' * 80)

# for循环二
for i in range(9, 0, -1):
    for a in range(1, i+1):
        print('{}*{}={:<4}'.format(a, i, a*i), end='')
    print()
print('-' * 80)

# for循环三
for i in range(9, 0, -1):
    for j in range(1, i):
        print('{:<8}'.format(''), end='')
    for j in range(10-i, 0, -1):
        print('{}*{}={:<4}'.format(j, 10-i, j*(10-i)), end='')
    print()
print('-' * 80)

# for循环四
for i in range(9, 0, -1):
    for j in range(9-i, 0, -1):
        print('{:<8}'.format(''), end='')
    for j in range(i, 0, -1):
        print('{}*{}={:<4}'.format(j, i, j*i), end='')
    print()
print('-' * 80)
